package flinkstudy.type;

import flinkstudy.bo.EstateInfo;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.typeutils.PojoTypeInfo;
import org.apache.flink.api.java.typeutils.RowTypeInfo;

/**
 * @author daocr
 * @date 2019/12/17
 */
public class CreateTypeInformation {

    /**
     * 简单的 pojo
     */
    public void pojoType() {
        PojoTypeInfo<EstateInfo> pojoTypeInfo = (PojoTypeInfo<EstateInfo>) TypeInformation.of(EstateInfo.class);
    }


    /**
     * 泛型 pojo
     */
    public void genericPojo() {
        TypeInformation<Tuple2<Integer, String>> pojoTypeInfo = TypeInformation.of(new TypeHint<Tuple2<Integer, String>>() {
        });
    }

    /**
     * 行数据
     */
    public void rowTypeInfo() {

        RowTypeInfo rowTypeInfo = new RowTypeInfo(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO);

        RowTypeInfo rowTypeInfo1 = new RowTypeInfo(new TypeInformation[]{Types.INT, Types.INT, Types.STRING}, new String[]{"id", "age", "name"});

    }


}
